package com.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String method=request.getParameter("method");
        if(method.equals("add")){
            request.getSession().setAttribute("msg","执行add方法");
        }

        if(method.equals("delete")){
            request.getSession().setAttribute("msg","执行delete方法");
        }

        //转发
        request.getRequestDispatcher("WEB-INF/jsp/test.jsp").forward(request,response);
        //重定向
        // response.sendRedirect(“index.jsp”);
       // response.getWriter().println("输出字符串给前端");
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request,response);
    }
}
